package com.stock.controller;

import com.stock.service.IStockService;
import com.stock.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/stock")
@CrossOrigin(origins = "*")
@Api(tags = "股票管理（旧）")
public class StockController {

    private final IStockService iStockService;

    public StockController(IStockService iStockService) {
        this.iStockService = iStockService;
    }

    @GetMapping("/getStock")
    @ApiModelProperty("测试-获取股票")
    public String getStock() {
        return "get stock success";
    }

    @GetMapping("/saveDataZT")
    @ApiModelProperty("保存涨停板")
    public String saveDataZT(@RequestParam(value = "beginDate") String beginDate) {
        iStockService.saveDataZT(beginDate);
        return "success";
    }

    @GetMapping("/saveDataAll")
    @ApiModelProperty("保存所有数据")
    public String saveDataAll(@RequestParam(value = "beginDate") String beginDate) {
        iStockService.saveDataAll(beginDate);
        return "success";
    }
    @GetMapping("/getStockDayData")
    @ApiModelProperty("获取明日数据（缓存处理）")
    public ResultVo getStockDayData(@RequestParam(required = false,
            defaultValue = "0") Integer type) {
        return ResultVo.success(iStockService.getStockDayData(type));
    }
    @GetMapping("/getStockYesterdayData")
    @ApiModelProperty("获取昨日数据（缓存处理）")
    public ResultVo getStockYesterdayData(@RequestParam(required = false,
            defaultValue = "0") Integer type) {
        return ResultVo.success(iStockService.getStockYesterdayData(type));
    }

}
